home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / setpgms.zip / SETREAD.DOC < prev   
Text File  |  1986-12-20  |  4KB  |  107 lines

  1. SETREAD   -  Use to restore the current directory
  2.  
  3. Requires DOS 2.0 or above and 2048 bytes of disk and memory space (not resident 
  4. when not in use).
  5.  
  6.  
  7.                  Copyright 1986, Arnold B. Krueger GPW MI 48236
  8.                       (ARNY KRUEGER @EXEC-PC 414-964-5160)
  9.                   Permission for free use and distribution by
  10.                   interested parties, not for profit, granted.
  11.  
  12. SETREAD reads the keyboard and places what it reads into the
  13. environment variable READSTR. Usage is:
  14.  
  15.              SETREAD  [flags] [name] [flags]
  16.        
  17.               "name" is the name of the environment variable set.
  18.                if none is supplied then READSTR is used.
  19.           
  20.               flags are: /U - make input upper case
  21.                          /L - make input lower case
  22.                          /F - read letters, numbers and F1-F9 as
  23.                               if they are function keys (no Cr rq'd)
  24.  
  25.  You can then refer to the named string in .BAT files
  26.      using its name delimited by percent signs ('%').
  27.     
  28.  For example: 
  29.       Echo name of program to run:
  30.       SETREAD  
  31.       echo  running: %readstr%
  32.       %readstr%
  33.  
  34.  errorlevels set are:
  35.                 0  if all goes well
  36.                 1  not at DOS 2.0 or above
  37.                 2  for environemnt setting errors:
  38.                          (an error message will be typed)
  39.                 3  for reading a null string
  40.                          (no error message or alteration
  41.                           of the environment will result)
  42.                 4  for ctrl-break
  43.                          (no error message or alteration
  44.                           of the environment will result)
  45.  
  46.  
  47. More complex example:
  48.  
  49.                  echo off
  50.                  echo Type in test string
  51.                  b:setread test %1
  52.                  if errorlevel 1 goto someerror
  53.                  echo Read: %test%
  54.                  goto exit
  55.  
  56.                  :someerror
  57.                   if errorlevel 4 goto ctrlbreak
  58.                   if errorlevel 3 goto nullread
  59.  
  60.                  :envfull
  61.                   echo environment setting error
  62.                   goto exit
  63.  
  64.                  :ctrlbreak
  65.                   echo ctrl-break detected
  66.                   goto exit 
  67.  
  68.                  :nullread
  69.                   echo null string read
  70.                   goto exit
  71.  
  72.                  :exit
  73.  
  74. This example is provided as READTEST.BAT. It is capable of demonstrating all
  75. the features of SETREAD. It is invoked:
  76.  
  77.                 TESTREAD [case_flag]
  78.  
  79.                 where case_flag is /U, /L, or null depending on the
  80.                       translation option desired. It prompts for
  81.                       a string, tests for errors, and types the string
  82.                       out if there are none.
  83.  
  84.  
  85. Design rationales:
  86.  
  87.        The /U and /L options facilitate comparing the read data since
  88.        users may type stuff in in either case, and the .BAT language
  89.        compares based on case. If you use the /L option, the string
  90.        will always be lower, and you can compare using only lower
  91.        case comparands.
  92.  
  93.        Null is treated as a special case since variables in the
  94.        environment cannot have null contents. If you set them to
  95.        null they disappear. Checking the errorlevel allows you
  96.        to handle this as a user error, or a deleting of the variable.
  97.  
  98.        Ctrl-Break is treated as a special case to provide a means
  99.        for handling them. Usually this is a "Cancel" command.
  100.  
  101. Future options:
  102.        Function key  handling
  103.        Multiple variables in one read
  104.        Substring operations
  105.        Notify the author as to what you want
  106.  
  107.